//
//  TTNewStyleController.swift
//  TTWeibo
//
//  Created by 陶宏路 on 16/7/23.
//  Copyright © 2016年 陶路路. All rights reserved.
//

import UIKit

class TTNewStyleController: UIViewController,UICollectionViewDataSource,UICollectionViewDelegate {

    
    lazy var collection:UICollectionView = {
        
        let layout = UICollectionViewFlowLayout()
        layout.itemSize = CGSizeMake(SCREENW, SCREENH)
        layout.scrollDirection = .Horizontal
        layout.minimumInteritemSpacing = 0
        layout.minimumLineSpacing = 0
        let collec = UICollectionView(frame: CGRectZero, collectionViewLayout: layout)
        collec.pagingEnabled = true
        
        collec.delegate = self
        collec.dataSource = self
        return collec
    }()
    
    
    override func loadView() {
        
        view = collection
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()

        self.view.backgroundColor = UIColor.orangeColor()
        
        collection.registerClass(TTNewStyleViewCell.self, forCellWithReuseIdentifier: "collection")
   
    }
    

    func numberOfSectionsInCollectionView(collectionView: UICollectionView) -> Int {
         return 1
    }
    
    func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
        
        return 4
    }
    
    
    func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
        
        let cell = collection.dequeueReusableCellWithReuseIdentifier("collection", forIndexPath: indexPath) as? TTNewStyleViewCell
        cell?.index = indexPath.item
        
        return cell!
    }
}
